/**
 * 肿瘤筛查系统API接口
 */
import http from '@/utils/http'

/**
 * 问卷相关接口
 */
export const questionnaireAPI = {
  // 提交问卷
  submit: (data: any) => {
    return http.post('/questionnaire/submit', data)
  },

  // 获取问卷详情
  getById: (id: string) => {
    return http.get(`/questionnaire/${id}`)
  }
}

/**
 * 风险评估接口
 */
export const assessmentAPI = {
  // 评估风险
  evaluate: (questionnaireId: string) => {
    return http.post(`/assessment/evaluate/${questionnaireId}`)
  },

  // 获取评估结果
  getById: (id: string) => {
    return http.get(`/assessment/${id}`)
  },

  // 获取用户所有评估记录
  getUserAssessments: (params?: any) => {
    return http.get('/assessment/user/list', { params })
  }
}

/**
 * 报告相关接口
 */
export const reportAPI = {
  // 获取报告详情
  getById: (id: string) => {
    return http.get(`/report/${id}`)
  },

  // 导出PDF
  exportPDF: (id: string) => {
    return http.post(
      `/report/${id}/export`,
      {},
      {
        responseType: 'blob'
      }
    )
  },

  // 生成分享链接
  createShare: (id: string, data: any) => {
    return http.post(`/report/${id}/share`, data)
  }
}

/**
 * 历史记录接口
 */
export const historyAPI = {
  // 获取历史记录列表
  getList: (params?: any) => {
    return http.get('/history/list', { params })
  },

  // 对比分析
  compare: (id1: string, id2: string) => {
    return http.get(`/history/compare`, {
      params: { id1, id2 }
    })
  }
}

/**
 * 管理后台接口
 */
export const adminAPI = {
  // 获取所有用户
  getUsers: (params?: any) => {
    return http.get('/admin/users', { params })
  },

  // 获取所有筛查记录
  getAssessments: (params?: any) => {
    return http.get('/admin/assessments', { params })
  },

  // 获取统计数据
  getStatistics: () => {
    return http.get('/admin/statistics')
  },

  // 禁用/启用用户
  toggleUserStatus: (userId: string, status: string) => {
    return http.put(`/admin/user/${userId}/status`, { status })
  }
}

